
<?php
require_once("../tools.php");
require_once("../bd_utils.php");
if(isset($_POST[ 'toUpdate'])){
$obj_utils=new bd_utils();
$obj_utils->connect();

$ids= $_POST[ 'idListing'];
$toUpdate= $_POST[ 'toUpdate'];
$nom= $_POST[ 'nom'];
$prenom= $_POST[ 'prenom'];
$dossard= $_POST[ 'dossard'];
$distance= $_POST[ 'distance'];
$club= $_POST[ 'club'];
$separator=",";
$br="<br>";


$cpt="";
for($i=0;$i<sizeof($toUpdate);$i++){
	for($j=0;$j<sizeof($ids);$j++){
		if($ids[$j]==$toUpdate[$i]){
			$cpt[$i]=$j;
		}
	}
}
for($i=0;$i<sizeof($cpt);$i++){
	$indice=$cpt[$i];
	$currentIds= $ids[$indice];
	$currentNom= $nom[$indice];
	$currentPrenom= $prenom[$indice];
	$currentDossard= $dossard[$indice];
	$currentDistance= $distance[$indice];
	$currentClub= $club[$indice];
	
	$obj_utils->updateUser($currentIds,$currentNom,$currentPrenom,$currentDossard,$currentDistance,$currentClub);
	
	echo "UPDATED: ".$currentNom." ".$currentPrenom." DISTANCE: ".$currentDistance." DOSSARD: ".$currentDossard." CLUB: ".$currentClub."<br>";
	
}
$obj_utils->close();
}
echo "<a href='http://127.0.0.1:8888/RunnerZ/index.php?page=inscriptions.php'>Get Back to Admin</a>";

//echo "ids".$br;
//echo listData($ids,$separator);
//echo $br;
//
//echo "toUpdate".$br;
//echo listData($toUpdate,$separator);
//echo $br;
//
//echo "nom".$br;
//echo listData($nom,$separator);
//echo $br;
//
//echo "prenom".$br;
//echo listData($prenom,$separator);
//echo $br;
//
//echo "dossard".$br;
//echo listData($dossard,$separator);
//echo $br;
//
//echo "club".$br;
//echo listData($club,$separator);
//echo $br;
?>